// This override doesn't look okay on a screen less than 900 pixels wide

// This version for ascension has the Guide right next to the main window where it cannot be ignored. A thiner chat is to the far right.
void guide(string menupaneHeight, string charpaneWidth, string chatVersion) {
	writeln('<frameset id=rootset cols="' + charpaneWidth + ',*,380">');
	writeln('  <frame name=charpane src="charpane.php"></frame>');
	writeln('  <frameset id=mainset rows="' + menupaneHeight + ',*">');
	writeln('    <frame name=menupane src="topmenu.php" scrolling=no></frame>');
	writeln('    <frameset id=center cols="*,319">');
	writeln('       <frame name=mainpane src="main.php"></frame>');
	writeln('       <frame name=guide src="relay_guide.ash"></frame>');
	writeln('    </frameset>');
	writeln('  </frameset>');
	writeln('  <frame name=chatpane src="' + chatVersion + '"></frame>');
	writeln('</frameset>');
}

// The aftercore version has a full sized chat window next to the main window since it is primary while a slim Guide is to the far right so you can check unused resources.
void guide2(string menupaneHeight, string charpaneWidth, string chatVersion) {
	writeln('<frameset id=rootset cols="' + charpaneWidth + ',*,224">');
	writeln('  <frame name=charpane src="charpane.php"></frame>');
	writeln('  <frameset id=mainset rows="' + menupaneHeight + ',*">');
	writeln('    <frame name=menupane src="topmenu.php" scrolling=no></frame>');
	writeln('    <frameset id=center cols="*,385">');
	writeln('       <frame name=mainpane src="main.php"></frame>');
	writeln('       <frame name=chatpane src="' + chatVersion + '"></frame>');
	writeln('    </frameset>');
	writeln('  </frameset>');
	writeln('  <frame name=guide src="relay_guide.ash"></frame>');
	writeln('</frameset>');
}

/*  KoL's original game.php

<html><head><title>The Kingdom of Loathing</title><script language="Javascript" src="/basics.js"></script><link rel="stylesheet" href="/basics.css" /></head>
<frameset id=rootset cols="4*,*">
  <frameset id=menuset rows="50,*">
    <frame name=menupane src="topmenu.php" scrolling=no></frame>
    <frameset id=mainset cols="200,*">
      <frame name=charpane src="charpane.php"></frame>
      <frame name=mainpane src="main.php"></frame>
    </frameset>
  </frameset>
  <frame name=chatpane src="chatlaunch.php"></frame>
</frameset>
<script src="/onfocus.js"></script></html>

// game.php rewritten by bordemstirs with full height charpane and no Guide. Not actually used unless I add an option. */
void noguide(string menupaneHeight, string charpaneWidth, string chatVersion) {
	writeln('<frameset id=rootset cols="' + charpaneWidth + ',3*,*">');
	writeln('  <frame name=charpane src="charpane.php"></frame>');
	writeln('  <frameset id=mainset rows="' + menupaneHeight + ',*">');
	writeln('    <frame name=menupane src="topmenu.php" scrolling=no></frame>');
	writeln('    <frame name=mainpane src="main.php"></frame>');
	writeln('  </frameset>');
	writeln('  <frame name=chatpane src="' + chatVersion + '"></frame>');
	writeln('</frameset>');
}

void main() {
	string page = visit_url();
	// Find the head html (1), closing html (5) and settings from KoL Options: Top menu style (2), Compact character pane (3) and Chat version (4)
	matcher KoLoptions = create_matcher('(.+?</head>).+?rows="(\\d+).+?id=mainset cols="(\\d+).+?chatpane src="([^"]+).+?(<script.*)', page);
	if(KoLoptions.find()) {
		writeln('<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">');
		writeln(KoLoptions.group(1));
		
		if(get_property("kingLiberated") == "true" && get_property("questM10Azazel") == "finished" && item_amount($item[abridged dictionary]) == 0 && get_campground() contains $item[pagoda plans])
			guide2(KoLoptions.group(2), KoLoptions.group(3), KoLoptions.group(4));
		else guide(KoLoptions.group(2), KoLoptions.group(3), KoLoptions.group(4));
		
		writeln(KoLoptions.group(5));
	} else writeln(page);
}



